package com.xjl.example.threadpool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by xiaojinlu1990@163.com on 2019/12/1.
 * 线程池的核心方法
 * 1 execute  调用线程功能执行
 * 2 submit  调用线程执行有返回值
 * 3 shoutDown  等任务执行完在停止
 * 4 shoutDownNew 立即结束执行
 *
 */
@Slf4j
public class ThreadPoolExample1 {

    public static void main(String[] args) {
        ExecutorService service = Executors.newFixedThreadPool(3);
        for (int i = 0; i <10; i++) {
            final int index = i;
            service.execute(() ->{
                log.info("{}",index);
            });
        }
        service.shutdown();
    }
}
